<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <script type="text/javascript">
//        $(function () {
//
//            $("#sortHead").headSort();
//        });

        function confirmDelete() {
            return confirm("<s:message code='confirmDelete'/>");
        }

        function optSingle(opt) {
            if (Cms.checkeds("ids") == 0) {
                alert("<s:message code='pleaseSelectRecord'/>");
                return false;
            }
            if (Cms.checkeds("ids") > 1) {
                alert("<s:message code='pleaseSelectOne'/>");
                return false;
            }
            var id = $("input[name='ids']:checkbox:checked").val();
            location.href = $(opt + id).attr("href");
        }

        function optDelete(form) {
            if (Cms.checkeds("ids") == 0) {
                alert("<s:message code='pleaseSelectRecord'/>");
                return false;
            }
            if (!confirmDelete()) {
                return false;
            }
            form.action = 'delete.do';
            form.submit();
            return true;
        }

        function confirmDeleteLive() {
          var msg="您确定删除当前直播？\n【请删除直播间和聊天室的全部内容以及栏目引用，否则无法删除】";
          return confirm(msg);
        }
    </script>
</head>
<body class="skin-blue content-body" id="load">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1>直播 - <s:message code="list"/>
        <small>(<s:message code="totalElements" arguments="${pagedList0.totalElements}"/>)</small>
    </h1>
</div>
<div class="content">
    <div class="box box-primary">
        <div class="box-body table-responsive">

            <div class="box-header with-border">
                <div id="radio">
                    <jsp:include page="types.jsp"/>
                </div>
            </div>
            <form class="form-inline ls-search" action="list.do?stat=${stat}" method="get">
                <div class="form-group">
                    <label>直播标题</label>
                    <f:text class="form-control input-sm" name="search_CONTAIN_title" value="${search_CONTAIN_title[0]}"
                            style="width:180px;"/>

                    <f:text class="form-control input-sm" name="search_EQ_status" value="${stat}"
                            style="width:180px; display:none; "/>
                </div>

                <button class="btn btn-default btn-sm" type="submit"><s:message code="search"/></button>
            </form>
            <form action="batch_update.do" method="post">
                <tags:search_params/>
                <div class="btn-toolbar ls-btn-bar">
                    <div class="btn-group">
                        <shiro:hasPermission name="ext:livebroadcast:create">
                            <button class="btn btn-default" type="button"
                                    onclick="location.href='create.do?${searchstring}&stat=${stat}';"><s:message
                                    code="create"/></button>
                        </shiro:hasPermission>
                    </div>

                </div>
                <table id="pagedTable" class="table table-condensed table-bordered table-hover ls-tb">
                    <thead id="sortHead" pagesort="<c:out value='${page_sort[0]}' />" pagedir="${page_sort_dir[0]}"
                           pageurl="list.do?page_sort={0}&page_sort_dir={1}&${searchstringnosort}">
                    <tr class="ls_table_th">
                        <%--<th width="25"><input type="checkbox" onclick="Cms.check('ids',this.checked);"/></th>--%>
                        <th width="30" class="ls-th-sort"><span class="ls-sort" pagesort="id">直播ID</span></th>
                        <th class="ls-th-sort" width="600"><span class="ls-sort">直播标题</span></th>
                        <th class="ls-th-sort"><span class="ls-sort">发布人</span></th>
                        <th class="ls-th-sort"><span class="ls-sort">真实点击量</span></th>
                        <c:choose>
                            <c:when test="${stat ne '0'}">
                                <th class="ls-th-sort"><span class="ls-sort" width="200">直播间</span></th>
                            </c:when>
                            <c:otherwise>
                                <th class="ls-th-sort"><span class="ls-sort" width="200">来源</span></th>
                                <th class="ls-th-sort"><span class="ls-sort" width="200">直播间</span></th>
                            </c:otherwise>
                        </c:choose>
                        <th class="ls-th-sort" width="180"><span class="ls-sort">开播时间</span></th>
                        <th class="ls-th-sort" width="80"><span class="ls-sort">状态</span></th>
                        <%--<th class="ls-th-sort"><span class="ls-sort">预约人数</span></th>--%>
                        <th width="300"><s:message code="operate"/></th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="bean" varStatus="status" items="${pagedList0.content}">
                        <tr<shiro:hasPermission
                                name="ext:livebroadcast:edit"> ondblclick="location.href=$('#edit_opt_${bean.id}').attr('href');"</shiro:hasPermission>>
                                <%--<td><input type="checkbox" name="ids" value="${bean.id}"/></td>--%>

                            <td align="center"><c:out value="${bean.id}"/></td>
                            <td align="center"><c:out value="${bean.title}"/></td>
                            <td align="center"><c:out value="${bean.compere}"/></td>
                            <td align="center"><c:out value="${bean.realviews}"/></td>
                                <%--<td align="center"><c:if test="${bean.status eq 0}"><c:out value="${bean.source}"/></c:if></td>--%>

                            <c:choose>
                                <c:when test="${bean.status!=0}">
                                    <td align="center">
                                        <a onclick="window.location.href='/cmscp/core/live_broadcast_room/list.do?id=${bean.id}&stat=${stat}'">进入直播间</a>
                                    </td>
                                </c:when>
                                <c:otherwise>
                                    <td align="center"><c:out
                                            value="${bean.source}"/></td>
                                    <td align="center">
                                        <a onclick="window.location.href='/cmscp/core/live_broadcast_room/list.do?id=${bean.id}&stat=${stat}'">进入直播间</a>
                                    </td>
                                </c:otherwise>
                            </c:choose>

                            <td align="center"><c:out value="${bean.time}"/></td>
                                <%--<td><c:choose><c:when test="${bean.status}"></c:when><c:otherwise></c:otherwise></c:choose></td>--%>

                            <td align="center"><s:message code="live.${bean.status}"/></td>
                            <%--<td align="center"><c:out value=""/></td>--%>

                            <td align="center">
                                <shiro:hasPermission name="ext:livebroadcast:genLives">
                                    <button class="btn btn-default" type="button"  onclick="$('#load').showLoading();location.href='generationLiveManage.do?liveId=${bean.id}&stat=${stat}&${searchstring}';">生成</button>
                                </shiro:hasPermission>
                                <shiro:hasPermission name="ext:livebroadcast:delLiveJson">
                                    <button class="btn btn-default" type="button" style="margin-left:2px;" onclick="$('#load').showLoading();location.href='delLiveJson.do?liveId=${bean.id}&stat=${stat}&${searchstring}';">清除分享页</button>
                                </shiro:hasPermission>
                                    <%--<shiro:hasPermission name="core:special:copy">--%>
                                    <%--<a id="copy_opt_${bean.id}" href="create.do?id=${bean.id}&${searchstring}" class="ls-opt"><s:message code="copy"/></a>--%>
                                    <%--</shiro:hasPermission>--%>
                                <shiro:hasPermission name="ext:livebroadcast:edit">
                                    <a id="edit_opt_${bean.id}" style="margin-left:15px;" href="edit.do?id=${bean.id}&position=${pagedList.number*pagedList.size+status.index}&${searchstring}&stat=${stat}"
                                       class="ls-opt"><s:message code="edit"/></a>
                                </shiro:hasPermission>
                                    <%--<shiro:hasPermission name="core:info:list">--%>
                                    <%--<c:url var="infoListUrl" value="../info/list.do">--%>
                                    <%--<c:param name="search_CONTAIN_JinfoSpecials.Jspecial.title" value="${bean.title}"/>--%>
                                    <%--</c:url>--%>
                                    <%--<a id="infoList_opt_${bean.id}" href="${infoListUrl}" class="ls-opt"><s:message code="special.infoList"/></a>--%>
                                    <%--</shiro:hasPermission>--%>
                                <shiro:hasPermission name="ext:livebroadcast:delete">
                                    <a href="delete.do?ids=${bean.id}&position=${pagedList.number*pagedList.size+status.index}&stat=${stat}&${searchstring}" onclick="return confirmDeleteLive();"
                                       class="ls-opt" style="margin-left:2px;">彻底删除</a>
                                </shiro:hasPermission>
                                    <%--<shiro:hasPermission name="core:site:delete">--%>
                                    <%--<c:choose>--%>
                                    <%--<c:when test="${bean.id==1}">--%>
                                    <%--<a class="ls-opt-disabled"><s:message code="recycle"/></a>--%>
                                    <%--</c:when>--%>
                                    <%--<c:otherwise>--%>
                                    <%--<a href="updateDelStatus.do?ids=${bean.id}&${searchstring}" onclick="return confirmDelete();" class="ls-opt"><s:message code="recycle"/></a>--%>
                                    <%--</c:otherwise>--%>
                                    <%--</c:choose>--%>
                                    <%--</shiro:hasPermission>--%>
                            </td>
                                <%--<td align="center"><fmt:formatDate value=""/></td>--%>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <c:if test="${fn:length(pagedList0.content) le 0}">
                    <div class="ls-norecord"><s:message code="recordNotFound"/></div>
                </c:if>
            </form>
            <form action="list.do" method="get" class="ls-page">
                <f:hidden name="stat" value="${stat}"/>
                <tags:search_params excludePage="true"/>
                <tags:pagination pagedList="${pagedList0}"/>
            </form>
        </div>
    </div>
</div>


</body>
</html>